package com.bdjk.bdmw.InfoGath.communication.persistence;

import com.bdjk.bdmw.InfoGath.business.beianbei.model.BeiAnBeiPositionModel;
import com.bdjk.bdmw.InfoGath.business.beianbei.model.BeiAnBeiShortModel;
import com.bdjk.bdmw.InfoGath.business.beianbei.service.BeiAnBeiAlarmService;
import com.bdjk.bdmw.InfoGath.business.beianbei.service.BeiAnBeiPushService;
import com.bdjk.bdmw.InfoGath.business.beianbei.service.BeiAnBeiPositionService;
import com.bdjk.bdmw.InfoGath.business.beianbei.service.impl.BeiAnBeiAlarmServiceImpl;
import com.bdjk.bdmw.InfoGath.business.beianbei.service.impl.BeiAnBeiPushServiceImpl;
import com.bdjk.bdmw.InfoGath.business.beianbei.service.impl.BeiAnBeiPositionServiceImpl;
import com.bdjk.bdmw.InfoGath.business.heremi.model.HereMiPositionModel;
import com.bdjk.bdmw.InfoGath.business.heremi.service.HereMiPositionService;
import com.bdjk.bdmw.InfoGath.business.heremi.service.impl.HereMiPositionServiceImpl;
import com.bdjk.bdmw.InfoGath.business.iparent.model.IparentPositionModel;
import com.bdjk.bdmw.InfoGath.business.iparent.service.IParentPositionService;
import com.bdjk.bdmw.InfoGath.business.iparent.service.impl.IParentPositionServiceImpl;
import com.bdjk.bdmw.InfoGath.business.nurse.model.NursePositionModel;
import com.bdjk.bdmw.InfoGath.business.nurse.service.NursePositionService;
import com.bdjk.bdmw.InfoGath.business.nurse.service.impl.NursePositionServiceImpl;
import com.bdjk.bdmw.InfoGath.common.constants.ProtocolConstants;
import com.bdjk.bdmw.InfoGath.common.model.BaseModel;

public class ChooseService {
	private void getService(String pattern){
		
	}
	
	public void saveMessage(String pattern,BaseModel model){
		String protocolName = ProtocolConstants.protocolMap.get(pattern);
		if(null != protocolName && protocolName.equals(ProtocolConstants.BEIANBEI_POSITION_NAME)){
			BeiAnBeiPositionService service = new BeiAnBeiPositionServiceImpl();
			if(model instanceof BeiAnBeiPositionModel){
				service.saveMessage((BeiAnBeiPositionModel) model);
			}
		}else if(protocolName.equals(ProtocolConstants.HEREMI_POSITION_NAME)){
			HereMiPositionService service=new HereMiPositionServiceImpl();
			if(model instanceof HereMiPositionModel){
				service.saveMessage((HereMiPositionModel) model);
			}
			
		}else if(protocolName.equals(ProtocolConstants.IPARENT_GPS_NAME)){
			IParentPositionService service=new IParentPositionServiceImpl();
			if(model instanceof IparentPositionModel){
				service.saveMessage((IparentPositionModel) model);
			}
		}else if(protocolName.equals(ProtocolConstants.NURSE_MULTILBS_NAME)||protocolName.equals(ProtocolConstants.NURSE_LBS_NAME)||protocolName.equals(ProtocolConstants.NURSE_GPS_NAME)){
			NursePositionService service=new NursePositionServiceImpl();
			if(model instanceof NursePositionModel){
				service.saveMessage((NursePositionModel) model);
			}
			
		}else if(protocolName.equals(ProtocolConstants.BEIANBEI_RESPOND_NAME)){
			BeiAnBeiPushService service = new BeiAnBeiPushServiceImpl();
			if(model instanceof BeiAnBeiShortModel){
				service.pushMessage((BeiAnBeiShortModel) model);
			}
		}else if(protocolName.equals(ProtocolConstants.BEIANBEI_ALARM_NAME)){
			if(model instanceof BeiAnBeiPositionModel){
				BeiAnBeiPositionService servPosition=new BeiAnBeiPositionServiceImpl();
				servPosition.saveMessage((BeiAnBeiPositionModel)model);
				BeiAnBeiAlarmService alarmService=new BeiAnBeiAlarmServiceImpl();
				alarmService.sendAlarmSet((BeiAnBeiPositionModel) model);
			}
			
		}
		else{
			return;
		}
	}
	
}
